Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Introduction
This document describes what you need to know to implement the Open() method of a part editor:
ODID Open(in ODFrame);
The Open() method is responsible for creating a window for the specified frame, and returning the ID of that window. If the window already exists, the method should simply activate it. The semantics are actually a little more complicated than this.
Open a Part from Nothing
When a new document is created from stationery, it contains no window state. In this case the Open() method of the root part is called by the OpenDoc shell, passing kODNULL as the frame.
Open an Embedded Frame
When the user selects a frame and chooses Open Selection from the document menu, the active part calls the selected part's Open() method, passing in the selected frame.
Open a Saved Document
New in DR2: When a document (actually a draft) is saved, the draft contains a list of root frames of persistently stored windows. OpenDoc annotates each root frame with a storage unit containing the window properties (bounding rectangle, etc.). When the document is opened, and the Window State internalized, the Window State calls the Open method of each frame's part, passing in the frame. The implementor of the Open() method can distinguish this case because the frame is a root frame, and contains the annotations. Utility functions are provided to access the window properties. See Window Utilities in the Utilities documentation.
Note: This means that windows are ALWAYS created by the parts, even when opening a saved document. Thus parts can and should do whatever they need to to adjust the window size and position to a given monitor configuration.
New in DR3: When an embedded selection is dragged to the Finder, and the source of the drag clones the selected frame, OpenDoc adds the frame to the root frame list of the newly-created document. In this case the Open() method will be called, and passed a root frame that has no window properties attached. So the Open() method should not assume that window properties are there.
View In Window
This menu item is handled by the active part itself, so it does not need to go through the Open() protocol at all, though a part editor may call some of the same internal methods.
Sample Code
Below is an example implementation of the Open() method from the Clock Part. Note the use of the utility functions BeginGetWindowProperties and EndGetWindowProperties, from WinUtils.h. BeginGetWindowProperties takes a (root) frame, and returns the window properties in a convenient struct, so that the part editor doesn't need to deal with the Storage API directly.